package com.li.controller;

import com.li.service.ContentService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@CrossOrigin
@RestController
public class ContentController {
    @Resource
    ContentService contentService;



    @PostMapping("/parse")
    public Boolean parse(String keyWords) throws Exception {
        return contentService.parseContent(keyWords);
    }

    @PostMapping("/searchPage")
    public List<Map<String, Object>> searchPage(@RequestParam(required = false) String keywords,
                                                @RequestParam (required = false) int pageNo,
                                                @RequestParam(required = false) int pageSize) throws IOException {
        if (StringUtils.isEmpty(keywords)) {
            keywords = "java";
        }
        return contentService.searchPage(keywords, pageNo, pageSize);
    }





}
